public class Test {
    public String name = "abcde";
    public String password = "12345678";
    public void login(String name,String password) throws UserNameException,PasswordException{
        if(!this.name.equals(name)){
            System.out.println("用户名错误");
            throw new UserNameException("你的用户名错了");
        }
        if(!this.password.equals(password)){
            System.out.println("密码错误");
            throw new PasswordException("你的密码错了");
        }
    }

    public static void main(String[] args) {
        Test test = new Test();
        try{
            test.login("wertd","23455");
        }catch(UserNameException e){
            e.printStackTrace();
            System.out.println("用户名异常");
        }catch(PasswordException e){
            e.printStackTrace();
            System.out.println("密码异常");
        }finally{

        }

    }
}
